/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "ramas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ramas.findAll", query = "SELECT r FROM Ramas r"),
    @NamedQuery(name = "Ramas.findByIdRama", query = "SELECT r FROM Ramas r WHERE r.idRama = :idRama"),
    @NamedQuery(name = "Ramas.findByRama", query = "SELECT r FROM Ramas r WHERE r.rama = :rama")})
public class Ramas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_Rama")
    private Integer idRama;
    @Size(max = 50)
    @Column(name = "Rama")
    private String rama;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idRama")
    private Collection<Subramas> subramasCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idRama")
    private Collection<Productos> productosCollection;

    public Ramas() {
    }

    public Ramas(Integer idRama) {
        this.idRama = idRama;
    }

    public Integer getIdRama() {
        return idRama;
    }

    public void setIdRama(Integer idRama) {
        this.idRama = idRama;
    }

    public String getRama() {
        return rama;
    }

    public void setRama(String rama) {
        this.rama = rama;
    }

    @XmlTransient
    public Collection<Subramas> getSubramasCollection() {
        return subramasCollection;
    }

    public void setSubramasCollection(Collection<Subramas> subramasCollection) {
        this.subramasCollection = subramasCollection;
    }

    @XmlTransient
    public Collection<Productos> getProductosCollection() {
        return productosCollection;
    }

    public void setProductosCollection(Collection<Productos> productosCollection) {
        this.productosCollection = productosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRama != null ? idRama.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ramas)) {
            return false;
        }
        Ramas other = (Ramas) object;
        if ((this.idRama == null && other.idRama != null) || (this.idRama != null && !this.idRama.equals(other.idRama))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.Ramas[ idRama=" + idRama + " ]";
    }
    
}
